package com.example.util;

public class Response<T> {
    private boolean flag;
    private String message;
    private int version;
    private int code;
    private T data;

    public Response() {
    }

    public Response(T data) {
        this.flag = true;
        this.message = "操作成功!";
        this.version = 1;
        this.code = 20000;
        this.data = data;
    }

    public Response(Throwable data) {
        this.flag = false;
        this.message = "请求异常,请联系管理员!!!";
        this.version = 1;
        this.code = 50000;
        this.data = (T) data;
    }

    public Response(int code, T data) {
        this.flag = false;
        this.message = "请求异常,请联系管理员!!!";
        this.version = 1;
        this.code = code;
        this.data = data;
    }

    public Response(int code, String message) {
        this.flag = false;
        this.message = message;
        this.version = 1;
        this.code = code;
    }

    public boolean isFlag() {
        return this.flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getVersion() {
        return this.version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String toString() {
        return "Response{flag=" + this.flag + ", message='" + this.message + '\'' + ", version=" + this.version + ", code=" + this.code + ", data=" + this.data + '}';
    }
}
